<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>双随机事项管理管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			var sx = '${drSx.sxFdsx}';
			if(sx==null||sx==""){ 
				$('.select-no').show();
			}else{ 
				$('.select-no').hide();
			}
			
			var copyThisA_ = $("#"+sx).clone();
			if ($("#selectA").length > 0) {
				$("#selectA a").html($(this).text());
			} else {
				$(".select-result dl").append(copyThisA_.attr("id", "selectA"));
			}
			
//			var zy = '${drSx.sxZy}';
//			var zy_arr = zy.split(",");
//			for(var i=0;i<zy_arr.length;i++){ 
//				var type = zy_arr[i];
//				var copyThisB = $("[date-type="+type+"]").clone();
//				if ($("[date-type="+type+"]").hasClass("selected_")) {
//					$(".select-result_ li[date-type='" + type + "']").remove();
//				} else {
//					$(".select-result_ ul").append(copyThisB);
//				};
//				$("[date-type="+type+"]").toggleClass("selected_");				
//			}
//			$(".select-result_ ul").delegate("li","click", function(){
//				var type = $(this).attr("date-type");
//				$(this).remove();
//				$("#select2_ li[date-type='" + type + "']").removeClass("selected_");
//			});		
//			$("#select2_ li").click(function() {
//				var type = $(this).attr("date-type");
//				var copyThisB = $(this).clone();
//				if ($(this).hasClass("selected_")) {
//					$(".select-result_ li[date-type='" + type + "']").remove();
//				} else {
//					$(".select-result_ ul").append(copyThisB);
//				};
//				$(this).toggleClass("selected_");
//			});	
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		function doSubmit(){
			var str = ""; 
			$(".select-result_").find("li").each(function(){
				str = str+$(this).attr("date-type")+",";
			});
			$('#sxZy').val(str);
			$('#inputForm').submit();
		}
		function doCopyName(str){ 
			$('#sxMc').val('${fns:getUser().getOffice()}'+'-'+str);
		}	
		function modifyName(){
			var hasChk = $('#xg').is(':checked');
			if(hasChk){
			    $('#xg').attr("checked",false);
			    $('#sxMc').attr("readonly",true);
			}else{
			    $('#xg').attr("checked",true);
			    $('#sxMc').attr("readonly",false);
			}
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
    		
		<li class="active"><a href="${ctx}/sx/drSx/formview?id=${drSx.id}"><c:choose><c:when test="${drSx.sxFlag eq '04'}">天津局事项查看</c:when><c:otherwise>法定事项查看</c:otherwise></c:choose></a></li>
        <c:if test="${empty drSx.id}"><li class="active"><a href="${ctx}/sx/drSx/zdyformview?id=${drSx.id}">自定义事项查看</a></li></c:if>
        <li><a href="${ctx}/sx/drSx/fdry?id=${drSx.id}">执法人员库查看</a></li>
        <li><a href="${ctx}/sx/drSx/fdsx?id=${drSx.id}">执法对象库查看</a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="drSx" action="${ctx}/sx/drSx/save" method="post" class="form-horizontal">
    	<input type="hidden" name="methodflag" id="methodflag" value=""/>
		<form:hidden path="id"/>
        <form:hidden path="sxZdy" value="0"/>
        <form:hidden path="sxZy" value=""/>
        <form:hidden path="officeZd" value="${fns:getUser().getOffice().id}"/>
		<sys:message content="${message}"/>
        <c:choose>
        	<c:when test="${drSx.sxFlag eq '04'}">		
                <div class="control-group">
                    <input type="hidden" name="could" id="could">
                    <label class="control-label">天津局事项：</label>
                    <div class="controls">
                        <ul class="select" style="margin-left:0px;">
                            <li class="select-list">
                                <dl id="select1">			
                                    <c:forEach items="${fns:getDictList('sys_user_could_tjj')}" varStatus="i" var="dic">
                                        <dd id="${dic.value}" <c:if test="${dic.value==drSx.sxFdsx}">class="selected"</c:if> style="min-width:300px;"><a href="javascript:void(0)">${dic.label}</a></dd>
                                    </c:forEach>        
                                </dl>
                            </li>
                            <li class="select-result">
                                <dl>
                                    <dt>已选条件：</dt>
                                    <dd class="select-no">没有选择天津局事项</dd>
                                    <form:input path="sxFdsx" htmlEscape="false" maxlength="255" class="input-xlarge required" style="width:0px;padding: 0 0 0 0;border:0px;"/>
                                    <span class="help-inline"><font color="red">*</font> </span>
                                </dl>
                            </li>      
                        </ul>
                    </div>            
                </div>
        	</c:when>
            <c:otherwise>
            	<div class="control-group">
            <input type="hidden" name="could" id="could">
            <label class="control-label">法定事项：</label>
            <div class="controls">
                <ul class="select" style="margin-left:0px;">
                    <li class="select-list">
                        <dl id="select1">			
                            <c:forEach items="${fns:getDictList('sys_user_could')}" varStatus="i" var="dic">
                                <dd id="${dic.value}" <c:if test="${dic.value==drSx.sxFdsx}">class="selected"</c:if> style="min-width:300px;"><a href="javascript:void(0)">${dic.label}</a></dd>
                            </c:forEach>        
                        </dl>
                    </li>
                    <li class="select-result">
                        <dl>
                            <dt>已选条件：</dt>
                            <dd class="select-no">没有选择双随机事项</dd>
                            <form:input path="sxFdsx" htmlEscape="false" maxlength="255" class="input-xlarge required" style="width:0px;padding: 0 0 0 0;border:0px;"/>
                            <span class="help-inline"><font color="red">*</font> </span>
                        </dl>
                    </li>      
                </ul>
            </div>            
        </div>
            </c:otherwise>
        </c:choose>    
		<div class="control-group">
			<label class="control-label">事项名称：</label>
			<div class="controls">
				<form:input path="sxMc" htmlEscape="false" maxlength="255" class="input-xxlarge required" readonly="true"/>
                <span class="help-inline"><font color="red">*</font> </span>
                <span class="help-inline" onClick="javascript:modifyName()" style="cursor: pointer"><input type="checkbox" id="xg"/>修改名称</span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">制定部门：</label>
			<div class="controls">
				${fns:getUser().getOffice()}
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">管理部门：</label>
			<div class="controls">
				<sys:treeselect id="office_gl" name="officeGl.id" value="${drSx.officeGl.id}" labelName="officeGl.name" labelValue="${drSx.officeGl.name}"
					title="管理部门" url="/sys/office/treeData?type=2}" cssClass="" allowClear="true" notAllowSelectParent="true"/>
			</div>
		</div>
        <!--<div class="control-group">
                    <label class="control-label">所需专业：</label>
                    <div class="controls">
                        
                        <div class="sousuo clearfix">
                            <div style="float:left;width:50px;"><font color="black">选择专业</font> </div>
                            <div class="select-result_ clearfix" style="float:right">
                                
                                <ul>
                                </ul>
                                
                            </div>
                        </div>       
                        <div class="updown_box">
                            <ul id="select2_">
                                <c:forEach items="${fns:getDictList('sys_user_zy')}" varStatus="i" var="dic">                      
                                <li date-type="${dic.value}"><a href="javascript:;">${dic.label}</a></li>                             
                                </c:forEach>                      
        
                            </ul>
                        </div>            
                        <input type="hidden" value="" id="selectposhidden" />	                                      
                    </div>
                </div>-->
		<div class="control-group">
			<label class="control-label">备注：</label>
			<div class="controls">
				<form:textarea path="sxBz" htmlEscape="false" maxlength="255" rows="4" class="input-xxlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<input id="btnCancel" class="btn" type="button" value="返 回" onClick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>